//
//  User.h
//  XPhoto
//
//  Created by baboy on 2019/6/26.
//  Copyright © 2019 baboy. All rights reserved.
//

#import "BKUser.h"
#import "PhotoAsset.h"

NS_ASSUME_NONNULL_BEGIN


#define API_AUTH_LOGIN                   @"user_login"
#define API_AUTH_LOGIN_BY_VCODE         @"user_login_by_vcode"
#define API_AUTH_REGISTER               @"user_register"
#define API_AUTH_REGISTER_MOBILE        @"user_register_mobile"
#define API_AUTH_REFRESH_TOKEN          @"user_refresh_token"


#define API_USER_SEND_BIND_MOBILE_VCODE         @"user_send_bind_mobile_vcode"
#define API_USER_SEND_REGISTER_MOBILE_VCODE     @"user_send_register_mobile_vcode"
#define API_USER_SEND_LOGIN_MOBILE_VCODE        @"user_send_login_mobile_vcode"

#define API_USER_BIND_MOBILE                    @"user_bind_mobile"

#define API_USER_PROFILE_ME                     @"user_profile_me"
#define API_USER_PROFILE_GET                    @"user_profile_get"
#define API_USER_PROFILE_UPDATE                 @"user_profile_update"
#define API_USER_PROFILE_UPDATE_USER_NAME       @"user_profile_update_user_name"
#define API_USER_PROFILE_UPDATE_COVER           @"user_cover_update"
#define API_USER_PROFILE_UPDATE_AVATAR          @"user_avatar_update"
#define API_USER_PROFILE_RESET_PASSWORD         @"user_profile_reset_password"

@interface UserRegisterMobileArgs : Model
@property(nonatomic, strong) NSString *mobile;
@property(nonatomic, strong) NSString *vcode;
@end

@interface User : BKUser
@property(nonatomic, strong) NSString *avatar;
@property(nonatomic, strong) NSString *mobile;
@property(nonatomic, strong) NSString *avatarThumb;
@property(nonatomic, strong) NSDictionary *authToken;
@property(nonatomic, assign) NSInteger gender;
@property(nonatomic, strong) NSString *intro;
@property(nonatomic, strong) NSString *cover;
@property(nonatomic, strong) NSString *banner;
@property(nonatomic, strong) NSString *bannerLink;
@property(nonatomic, assign) NSInteger postCount;
@property(nonatomic, assign) NSInteger fanCount;
@property(nonatomic, assign) NSInteger followCount;
@property(nonatomic, assign) BOOL following;
@property(nonatomic, assign) BOOL fan;

+ (id)loginWithUserName:(NSString *)userName
               password:(NSString *)password
               callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)refreshTokenWithUser:(User *)user
               callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)signup:(User *)user
    callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;


+ (id)sendBindMobileVCode:(NSString *)mobile
    callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)sendRegisterMobileVCode:(NSString *)mobile
                     callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
+ (id)sendLoginMobileVCode:(NSString *)mobile
                  callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)loginWithMobile:(NSString *)mobile
               vcode:(NSString *)vcode
               callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
/**
 * user:  {@"mobile": xxx, @"vcode": yyy}
 */
+ (id)signupWithMobile:(UserRegisterMobileArgs *)args
              callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)bindMobile:(NSString *)mobile
           vcode:(NSString *)vcode
        callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)resetPassword:(NSDictionary *)args
        callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;



+ (id)update:(User *)user
         callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)updateUserName:(NSString *)userName
         callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)getUserProfile:(NSInteger)uid
         callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
+ (id)getLoginUserProfileWithCallback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)updateCover:(PhotoAsset *)photoAsset
photoUploadProgress:(void(^)(NSString *key, float p))progress
         callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)updateAvatar:(PhotoAsset *)photoAsset
photoUploadProgress:(void(^)(NSString *key, float p))progress
          callback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)uploadAvatar:(PhotoAsset *)photoAsset
photoUploadProgress:(void(^)(NSString *key, float p))progress
          callback:(nullable void (^)(id _Nonnull info, id _Nullable ret,  NSError * _Nullable error))callback;
@end

NS_ASSUME_NONNULL_END
